<?php
/**
 * True Cart Shop Component for Joomla CMS
 *
 * @version 2.5
 * @author Alexey N. Brin (userxp@joomlaportal.ru)
 * @homepage http://joomlatune.ru 
 * @filename defines.php
 * @package True Cart Shop
 * @copyright (C) 2008-2009 by joomlatune.ru
 * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
 * 
 * If you fork this to create your own project, 
 * please make a reference to True Gallery someplace in your code 
 * and provide a link to http://www.joomlatune.ru
 *
 **/

defined('_JEXEC') or die('Direct Access to this location is not allowed.');
require_once( dirname(__FILE__).DS.'libraries'.DS.'joomlatune'.DS.'config.php' );

//print_r( "\n\n<br /><br /> after connecting jtune config.php: " . (getmicrotime()-MCTIME) );

if( !defined( 'TG_COM' ) ) {
	define( 'TG_COM',			'true' );
	define( 'TG_CMP',			'com_' . TG_COM );
	define( 'TG_TBLPREFIX',		'#__' . TG_COM );
	define( 'TG_VERSION',		'2.5 Alpha ' );
	define( 'TG_BUILD',			'#111' );
	define( 'TG_CMP_NAME',		'True Gallery' );
	define( 'TG_WMARK_PREFIX',	'WM_' );
	define( 'TG_PACK',			false ); // choose TRUE if you want to pack CSS & JS in header
	define( 'TG_ADMINPATH',		JTuneConfig::getPath('adminpath', TG_CMP) );
	define( 'TG_ADMINWAY',		JTuneConfig::getPath('adminway', TG_CMP) );
	define( 'TG_FRONTWAY',		JTuneConfig::getPath('frontway', TG_CMP) );
	define( 'TG_FRONTPATH',		JTuneConfig::getPath('frontpath', TG_CMP) );
	define( 'TG_FRONTURL',		'index.php?option='.TG_CMP );
	define( 'TG_LIBRARIES',		TG_ADMINPATH .'libraries'.DSX );
	define( 'TG_VIEWSPATH',		TG_FRONTPATH .'views'.DSX );
	define( 'TG_VIEWSWAY',		TG_FRONTWAY  .'views/' );
	define( 'TG_IMAGESWAY', 	TG_VIEWSWAY  .'default/tmpl/default/images/' );
	define( 'TG_IMAGESPATH', 	TG_FRONTPATH .'views'.DSX.'default'.DSX.'tmpl'.DSX.'default'.DSX.'images'.DSX );
	define( 'TG_PLUGINSPATH',	TG_ADMINPATH .'plugins'.DSX );
	define( 'TG_PLUGINSWAY',	TG_ADMINWAY  .'plugins/' );
	define( 'TG_JTUNE',			TG_LIBRARIES.'joomlatune'.DSX );
	define( 'TG_XPLIB',			TG_JTUNE ); // Legacy. do not use in future
	define( 'TG_LEGACY',		TG_JTUNE.'legacy'.DSX );
	
	$config		= &JTuneConfig::load(TG_CMP);
	$ad_path	= $config->getValue( 'ad_path' );
	$path		= slashFixer( JPATH_SITE.DSX.$ad_path ).DSX;
	$config->setTitleHandler('JTrueGalleryPageHelper');
	
//print_r( "\n\n<br /><br /> after load jtune config: " . (getmicrotime()-MCTIME) );
	
	define( 'TG_GALLERIES', 	str_replace( '//', '/', JTuneConfig::buildPath('front','way').$ad_path.'/' ) );
	define( 'TG_THUMBSPATH', 	$path.'thumbs'.DSX );
	define( 'TG_PICTURESPATH', 	$path.'pictures'.DSX );
	define( 'TG_ORIGINALSPATH', $path.'originals'.DSX );
	define( 'TG_THUMBSWAY',		TG_GALLERIES.'thumbs/' );
	define( 'TG_PICTURESWAY',	TG_GALLERIES.'pictures/' );
	define( 'TG_ORIGINALSWAY',	TG_GALLERIES.'originals/' );
	define( 'TG_AX',			'ax=1&no_html=1' );
	define( 'TG_AJAX',			checkAJAX() );
	define( 'TG_MEDIA',			str_replace( '\\', '/', JPATH_ROOT.DSX . 'media' ) );
}

// AX.PHP protection
if( !defined( 'TGAX' ) ) {
	require_once( TG_JTUNE.'router.php' );
	require_once( TG_LIBRARIES.'legacy.php' );

	if( $config->is_admin() ) {
		require_once( TG_ADMINPATH.'admin.true.html.php' );
		require_once( TG_JTUNE.'html.php');
	}
}
require_once( TG_LIBRARIES.'functions.php' );

// AX.PHP protection
if( !defined( 'TGAX' ) ) {
	require_once( TG_JTUNE.'table.php' );
	require_once( TG_LIBRARIES.'class.true.php' );
	// defining js variables
	$header = '
	<script>
		TG_CMP			= \''.TG_CMP.'\';
		TG_FRONTURL		= \''.TG_FRONTURL.'\';
		TG_FRONTWAY		= \''.TG_FRONTWAY.'\';
		TG_ADMINWAY		= \''.TG_ADMINWAY.'\';
		TG_THUMBSWAY	= \''.TG_THUMBSWAY.'\';
		TG_PICTURESWAY	= \''.TG_PICTURESWAY.'\';
		TG_ORIGINALSWAY	= \''.TG_ORIGINALSWAY.'\';
		TG_GALLERIES	= \''.TG_GALLERIES.'\';
		TG_TEMPLATESWAY	= \''.TG_VIEWSWAY.'\';
		TG_VIEWSWAY		= \''.TG_VIEWSWAY.'\';
		TG_IMAGESWAY	= \''.TG_IMAGESWAY.'\';
		TG_AX			= \''.TG_AX.'\';
	</script>
	';
	$app = &JTuneConfig::getApplication();
	$app->addCustomHeadTag( $header );
}

//print_r( "\n\n<br /><br /> after load DEFINES: " . (getmicrotime()-MCTIME) );
?>